cssshadowvalue: Add a parsing function
authorMatthias Clasen <mclasen@redhat.com>
Sat, 6 Feb 2021 02:36:22 +0000 (21:36 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 6 Feb 2021 02:36:22 +0000 (21:36 -0500)
Add a variant of the parse function that parses
just a single (non-box) shadow, as required for
the drop-shadow filter.

gtk/gtkcssshadowvalue.c
gtk/gtkcssshadowvalueprivate.h

index 126e9af8f2262ab695a3b2ff1a13fb254da92014..b7b409ca72b46670b5bab7d32d32c460973474f3 100644 (file)
@@ -326,6 +326,21 @@ gtk_css_shadow_value_new (ShadowValue *shadows,
   return retval;
 }
 
+GtkCssValue *
+gtk_css_shadow_value_new_filter (void)
+{
+  ShadowValue value;
+
+  value.inset = FALSE;
+  value.hoffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+  value.voffset = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+  value.radius = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+  value.spread = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
+  value.color = _gtk_css_color_value_new_current_color ();
+
+  return gtk_css_shadow_value_new (&value, 1);
+}
+
 enum {
   HOFFSET,
   VOFFSET,
@@ -497,6 +512,22 @@ fail:
   return NULL;
 }
 
+GtkCssValue *
+_gtk_css_shadow_value_parse_filter (GtkCssParser *parser)
+{
+  GtkCssValue *result;
+
+  result = _gtk_css_shadow_value_parse (parser, FALSE);
+
+  if (result && result->n_shadows != 1)
+    {
+      gtk_css_parser_error_syntax (parser, "A single shadow is required");
+      g_clear_pointer (&result, gtk_css_value_unref);
+    }
+
+  return result;
+}
+
 void
 gtk_css_shadow_value_get_extents (const GtkCssValue *value,
                                   GtkBorder         *border)
index 5784dfa5168e56c41f25275630d0381184b86133..3f49963b5b4d4207e6a99aa2f8cbe395c7b6127a 100644 (file)
 G_BEGIN_DECLS
 
 GtkCssValue *   gtk_css_shadow_value_new_none            (void);
+GtkCssValue *   gtk_css_shadow_value_new_filter       (void);
 
 GtkCssValue *   _gtk_css_shadow_value_parse           (GtkCssParser             *parser,
                                                        gboolean                  box_shadow_mode);
+GtkCssValue *   _gtk_css_shadow_value_parse_filter    (GtkCssParser             *parser);
 
 void            gtk_css_shadow_value_get_extents      (const GtkCssValue        *shadow,
                                                        GtkBorder                *border);